export function useModel<T, K extends Extract<keyof T, string>>(props: T, propName: K, emit: (e: string, value: any) => void) {
    
    const propValue = props[propName];

    // 确保 propValue 是一个对象
    if (typeof propValue !== 'object' || propValue === null) {
        throw new Error(`Expected prop ${propName} to be an object`);
    }
    
    return computed({

        get() {
            return new Proxy(propValue, {
                set(obj, key, value) {
                    emit(`update${propName}`,{
                        ...obj,
                        [key]: value
                    })
                    return true
                }
            })
        },
        set(value) {
            emit(`update${propName}`, value)
        }
    })
}